import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

df = pd.read_excel('stock(2).xlsx', dtype={'code': 'str'})
df.set_index('code', inplace=True)
df.loc['002522']
len(df.industry.unique())
len(df.area.unique())
df.groupdy('area').area.count().sort_values(acending=False)
year = df.timeToMarket.astype('str').str[:4]
yearnum = df.groupdy(year).name.count()
yearnum[yearnum.index != '0'].plot(fontsize=14, title='年TOP数量')
df.pe.mean()
df[df.pe > 0].pe.mean()
df['tvalue'] = 4*df.esp*df.pe*df.totsls
np.sum(df.pe * df.tvalue) / df.tvalue.sum()
df['board'] = df.set_index.str[:2]
df.groupby('board').pe.agg([('pe均值', 'mean'), ('股票数', 'count')])

print()